package com.ibeeking.found.cop.b.rest.controller.v1;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ibeeking.found.cop.b.rest.service.IMsgFansMomentService;
import com.ibeeking.found.cop.service.common.param.MsgFansMomentParam;
import com.ibeeking.found.cop.service.common.query.MsgFansMomentPageQuery;
import com.ibeeking.found.cop.service.common.query.MsgFansMomentQuery;
import com.ibeeking.found.cop.service.common.vo.MsgFansMomentVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.ibeeking.nematos.utils.base.BaseValidationGroup;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName MsgFansMomentController
 * @Description
 * @Author ibeeking
 * @Date 2021-06-02 18:15
 **/
@RestController
@RequestMapping("/b/msgFansMoment/v1")
public class MsgFansMomentController {

    @Resource
    private IMsgFansMomentService msgFansMomentServiceImpl;

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询朋友圈信息列表")
    @PostMapping(value = "/list")
    public List<MsgFansMomentVO> list(@RequestBody MsgFansMomentQuery query) {
        return msgFansMomentServiceImpl.list(query);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询朋友圈信息分页列表")
    @PostMapping(value = "/pageList")
    public Page<MsgFansMomentVO> pageList(@RequestBody MsgFansMomentPageQuery pageQuery) {
        return msgFansMomentServiceImpl.pageList(pageQuery);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "添加朋友圈信息")
    @PostMapping(value = "/add")
    public Boolean add(@RequestBody @Validated(BaseValidationGroup.Insert.class) MsgFansMomentParam param) {
        return msgFansMomentServiceImpl.add(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改朋友圈信息")
    @PostMapping(value = "/modify")
    public Boolean modify(@RequestBody @Validated(BaseValidationGroup.Update.class) MsgFansMomentParam param) {
        return msgFansMomentServiceImpl.modify(param);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "复制朋友圈消息")
    @PostMapping(value = "/copy/{id}")
    public Boolean copy(@PathVariable("id") Long id) {
        return msgFansMomentServiceImpl.copy(id);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改是否启用")
    @GetMapping(value = "/changeStatus/{id}/{status}")
    public Boolean changeStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        return msgFansMomentServiceImpl.changeStatus(id, status);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查看朋友圈信息详情")
    @GetMapping(value = "/view/{id}")
    public MsgFansMomentVO view(@PathVariable("id") Long id) {
        return msgFansMomentServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "删除朋友圈信息")
    @GetMapping(value = "/del/{id}")
    public Boolean del(@PathVariable("id") Long id) {
        return msgFansMomentServiceImpl.del(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "发送朋友圈消息")
    @PostMapping(value = "/sendWxCpFansMoment/{id}")
    public Boolean sendWxCpFansMoment(@PathVariable("id") Long id) {
        return msgFansMomentServiceImpl.sendWxCpFansMoment(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "取消发送朋友圈消息")
    @PostMapping(value = "/stopWxCpFansMoment/{id}")
    public Boolean stopWxCpFansMoment(@PathVariable("id") Long id) {
        return msgFansMomentServiceImpl.stopWxCpFansMoment(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "刷新朋友圈发布记录")
    @PostMapping(value = "/refreshWxCpFansMomentPublishRecord")
    public Boolean refreshWxCpFansMomentPublishRecord() {
        return msgFansMomentServiceImpl.refreshWxCpFansMomentPublishRecord();
    }

}
